package action.agent;

import org.apache.struts2.ServletActionContext;

import security.MySecurityContextHandle;
import service.interf.IOperationLog;
import action.common.MyBaseAction;

import com.opensymphony.xwork2.ModelDriven;
import common.impl.exception.ServiceException;

import dao.pojo.OperationLog;

/**
 * 操作日志
 * 
 * @author Administrator
 * 
 */
public class OperationLogAction extends MyBaseAction<OperationLog> implements
		ModelDriven<OperationLog> {

	private static final long serialVersionUID = 1L;
	private IOperationLog iOperationLog;

	public void setiOperationLog(IOperationLog iOperationLog) {
		this.iOperationLog = iOperationLog;
	}

	public OperationLogAction() {
		super(OperationLog.class);
	}

	public OperationLog getModel() {
		return model;
	}

	/**
	 * 获取列表
	 */
	public void getlist() {
		String r;
		try {
			r = iOperationLog.getList(model.getPage(), model.getRows());
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient(ServletActionContext.getResponse(), r);
	}

	/**
	 * 批量删除
	 */
	public void delbatch() {
		String r;
		try {
			// 验证
			String userName = MySecurityContextHandle.getUserName();
			if (!"admin".equals(userName))
				throw new ServiceException("请先登录");
			iOperationLog.delByIds("OperationLog", "id", model.getIds());
			r = "1";
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient1(ServletActionContext.getResponse(), r);
	}
}
